package com.qingke.p1;

public class Rectangle extends Shape{
	double length = 1.0;
	double  width = 1.0;
	public Rectangle(){
		
	}
	public Rectangle(double length,double width){
		this.length=length>0?length:1;
		this.width=width>0?width:1;
	}
	public Rectangle(double length,double width,String color,boolean filled){
		super(color,filled);
		this.length=length>0?length:1;
		this.width=width>0?width:1;
	}
	public double getLength() {
		return length;
	}
	public void setLength(double length) {
		if(length>0)
			this.length = length;
	}
	public double getWidth() {
		return width;
	}
	public void setWidth(double width) {
		if(width>0)
			this.width = width;
	}
	public double getArea() {
		return length*width;
	}
	public double getPerimeter() {
		return length+length+width+width;
	}
	public String toString() {
		return "Rectangle[length="+length+",width="+width+"]";
	}
}
